<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>InfinityJEEEU Java Code Generator</title>
        <link href="../css/default.css" rel="stylesheet" type="text/css" />
        <link href="../lib/codemirror.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../lib/codemirror.js"></script>
        <script type="text/javascript" src="../js/sgs.js"></script>
        <script type="text/javascript" src="../js/clike.js"></script>
        <script type="text/javascript" src="../js/javascript.js"></script>
        <script type="text/javascript" src="../js/htmlmixed.js"></script>
        <script type="text/javascript" src="../js/xml.js"></script>
        <script type="text/javascript" src="../js/vue.js"></script>
    </head>   
    <body onload="setSample()">
        <div id="wrapper">
        <div id="header_wide">
    <div id="logo">
        <h1><a href="../html/index.html">无垠式Java通用代码生成器</a></h1>
        <h2><a href="../html/index.html">自2014年起为公众服务</a></h2>
    </div>
    <!-- end div#logo -->
    <!-- end div#menu -->
</div>
            <!-- end div#header -->
            <div id="page_wide">
                <div id="content">
                    <div id="welcome">
                    	<h2>无敌替换王</h2>
                    	<table> 
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3"><select id="langSelect" onchange="switchLang()">
                    			<option value="text/x-java" selected="">Java</option>
                    			<option  value="text/javascript">JavaScript</option>
                    			<option  value="application/json">JSON</option>
                    			<option  value="text/html">HTML</option>
                    			<option  value="text/xml">XML</option>
                    			<option  value="text/x-vue">Vue</option>
                    			<option  value="text/sgs">SGS</option>
                    		</select></td>
                    	</tr>
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3">原词1：<input type="text" id="param1" name="param1">替换1:<input type="text" id="target1" name="target1">自动复数1:<input type="checkBox" id="autoplural1" checked="true"></td>
                    	</tr>
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3">原词2：<input type="text" id="param2" name="param2">替换2:<input type="text" id="target2" name="target2">自动复数2:<input type="checkBox" id="autoplural2" checked="true"></td>
                    	</tr>
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3">原词3：<input type="text" id="param3" name="param3">替换3:<input type="text" id="target3" name="target3">自动复数3:<input type="checkBox" id="autoplural3" checked="true"></td>
                    	</tr>
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3">原词4：<input type="text" id="param4" name="param4">替换4:<input type="text" id="target4" name="target4">自动复数4:<input type="checkBox" id="autoplural4" checked="true"></td>
                    	</tr>
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3">原词5：<input type="text" id="param5" name="param5">替换5:<input type="text" id="target5" name="target5">自动复数5:<input type="checkBox" id="autoplural5" checked="true"></td>
                    	</tr>
                    	<tr 　style="font-size:16pt">
                    		<td colspan="3"><input type="button" id="replaceBtn" value="全部替换" onclick="processData()"><input type="button" id="resetBtn" value="重置" onclick="reset()")></td>
                    	</tr>
                    	<tr>
                    	<td>                     
						<div style="float:left;font-size:12pt">输入窗口：</div>
						<form id="codeForm" action="" method="post">
                        <textarea id="mycode" name="mycode" onchange="colorCode()">
						</textarea>
                        </form>
                        </td>
                        <td style="width:10px">
                        </td>
                        <td>
                        <div style="float:left;font-size:12pt">输出窗口：</div>
                        <textarea id="myresult" name="myresult">
						</textarea>
                        </td>
                        </tr>  
                        </table>   
                    </div>
                    <!-- end div#welcome -->
                </div>
                <!-- end div#content -->
                <div id="sidebar">
                    <!--ul-->
                    	<!-- Common Navigation Panel for our site -->
						<li id="submenu">
						    <h2>功能菜单</h2>
						    <ul>
						      <li><a href="../html/index.html">使用SGS生成代码</a></li>
						      <li><a href="../html/parseexcel.html">使用Excel生成代码</a></li>
							  <li><a href="../tools/multiTokenReplacer.html">无敌替换王</a></li>
<!-- 							  <li><a href="../tools/sqlGenerator.html">果核里的SQL</a></li> -->
<!-- 							  <li><a href="../tools/dataFormatGenerator.html">数据变形虫</a></li> -->
<!-- 							  <li><a href="../tools/htmlTokenGenerator.html">HTML造砖匠</a></li> -->
<!-- 							  <li><a href="../tools/urlEncodeParser.html">URL加密解密</a></li> -->
<!-- 							  <li><a href="../tools/utf8EncodeParser.html">UTF8加密解密</a></li> -->
<!-- 							  <li><a href="../tools/base64EncodeParser.html">Base64加密解密</a></li> -->
						    </ul>
						</li>
                    <!--/ul-->
                </div>
                <!-- end div#sidebar -->
                <div style="clear: both; height: 1px"></div>
            </div>
            <!-- Common footer for our site -->
			<div id="footer_wide">
			    <p id="legal">作者：火鸟  电邮:jerry_shen_sjf@qq.com QQ群:277689737<br/>
			    </p>
			</div>
        </div>
        <!-- end div#wrapper -->
<script type="text/javascript">
var sampleStr = "	@Override\n"+
"	@Transactional\n" +
"	public Boolean revokePrivilegesFromRole(Long roleId,String privilegeIds) throws Exception{\n" +
"		String [] privilegeIdsArr = privilegeIds.split(\",\");\n" +
"		for (int i = 0; i < privilegeIdsArr.length; i++ ){\n" +
"\n" +
"		Long privilegeId = Long.parseLong(privilegeIdsArr[i]);\n" +
"\n" +
"		Integer success = dao.revokePrivilegeFromRole(roleId,privilegeId);\n" +
"		if (success < 0) return false;\n" +
"		}\n" +
"		return true;\n" +
"	}\n";

var　mymode = $("#langSelect").val();
var editor = CodeMirror.fromTextArea($("#mycode")[0],
		{	mode:mymode,indentUnit:4,
			lineNumbers: true
	});
editor.setSize('40em','60em');

var editor2 = CodeMirror.fromTextArea($("#myresult")[0],
		{	mode:mymode,indentUnit:4,
			lineNumbers: true
	});
editor2.setSize('40em','60em');

function setSample(){
	$("#mycode").text(editor.getValue(editor.setValue(sampleStr)));
	$("#param1").val("Role");
	$("#target1").val("Privilege");
}

function switchLang(){
	mymode = $("#langSelect").val();
	editor.setOption("mode",mymode);
	editor2.setOption("mode",mymode);
}
  
function processData(){
	$.ajax({
        type: "post",
        url: "../facade/multiTokenReplacerFacade",
        data: {mycode:editor.getValue(),
        	   param1:$("#param1").val(),
        	   target1:$("#target1").val(),
        	   autoplural1:$("#autoplural1").val(),
        	   param2:$("#param2").val(),
        	   target2:$("#target2").val(),
        	   autoplural2:$("#autoplural2").val(),
        	   param3:$("#param3").val(),
        	   target3:$("#target3").val(),
        	   autoplural3:$("#autoplural3").val(),
        	   param4:$("#param4").val(),
        	   target4:$("#target4").val(),
        	   autoplural4:$("#autoplural4").val(),
        	   param5:$("#param5").val(),
        	   target5:$("#target5").val(),
        	   autoplural5:$("#autoplural5").val()        	   
		},
		async:false,
        dataType: 'text',
        success: function(data, textStatus) {
        	debugger;
        	if ( data != null & data!=""){
         	   $("#myresult").text(editor2.getValue(editor2.setValue(data)));        	   
            }       
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function reset(){
	alert("Haha!");
}
</script>        
</body>
</html>
